package utils

import "strings"

func ConvertSlice[SOURCE any, TARGET any](sourceSlice []SOURCE, converter func(source SOURCE) TARGET) []TARGET {
	if sourceSlice == nil {
		return nil
	}
	targetSlice := make([]TARGET, 0)
	for _, source := range sourceSlice {
		targetSlice = append(targetSlice, converter(source))
	}
	return targetSlice
}

func Lower1stChar(s string) string {
	runes := []rune(s)
	first := string(runes[0:1])
	return strings.ToLower(first) + string(runes[1:])
}

func SliceEmpty[T any](slice []T) bool {
	return slice == nil || len(slice) == 0
}

func SliceIsNotEmpty[T any](slice []T) bool {
	return !SliceEmpty(slice)
}
